require "NodeManager"
require "WarScene"

NodeID={HeroTableBK=3001, TongShuaiLabelOld=3002, ZhanShuLableOld=3003, BaoPoLabelOld=3004, 
        TongShuaiLabelNew=3005, ZhanShuLableNew=3006, BaoPoLabelNew=3007}

TrainHeroScene.heros = {"hero13", "hero14", "hero15", "hero17", "hero18", "hero19"}

TrainHeroScene={}
TrainHeroScene.getNode = function()
  TrainHeroScene.node = CCBReader:load("TrainHeroHD.ccbi")  
  return TrainHeroScene.node
end

TrainHeroScene.initTable = function()
  local heroTableBK = TrainHeroScene.node:getChildByTag(NodeID.HeroTableBK)
  local size=heroTableBK:getContentSize()
  local items = CCArray:create()
  local count = #TrainHeroScene.heros
  for i=0,count-1 do
    local name = TrainHeroScene.heros:objectAtIndex(i)
    local layer = CCLayer:create()
    local button=CCButton:createWithFileName("onSelectHero","UI92.png","UI92.png","UI92.png") 
    local herosp=CCSprite:create(string.format("%s.png",name))
    layer:addChild(button)
    layer:addChild(herosp)
    items:addObject(layer)
    NodeManager:addObject(name, button)
  end
  local tableview = CCTableView:create(1, CCSizeMake(size.width, size.height), items)
  local x, y = ActionUtil.leftBottomPoint(heroTableBK)
  tableview:setPosition(x+10, y)
  TrainHeroScene.node:addChild(tableview)  
end

function onSelectHero(node)
  local name = NodeManager:getName(node)
      
end 
